// index.js
let network = require("../../utils/network/network.js")
let api = require("../../utils/network/config.js").api;
let getUserProfile = require("./../../utils/login").getUserProfile;

// 获取应用实例
const app = getApp()
Page({

  data: {
    detectList: [],
    scanCount: 0,
    orderCount: 0,
    stickCount: 0
  },
  onShow() {

    this.getIndexPageInfo()
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 0
      })
    }

  },
  gotoIdentify() {
    wx.navigateTo({
      url: '/pages/recongnitionlist/recongnitionlist',
    })
  },
  getIndexPageInfo() {

    network.fetch({
        url: api.index_info,
        inBody: false,
        data: {
          userId: 22
          //userId: getApp().globalData.userInfo.uid
        },
        method: 'GET',
      })
      .then(res => {
        console.log(res)
        let detectList = res.data.detectList
        detectList.forEach((ele, index) => {
          detectList[index].detectTime = ele.detectTime.substr(5, 11)
        });
        this.setData({
          detectList: detectList,
          scanCount: res.data.scanCount,
          orderCount: res.data.orderCount,
          stickCount: res.data.stickCount
        })
      })
  },
  gotoScan() {
    wx.navigateTo({
      url: './../camara/camara',
    })
  },
  gotoData() {
    wx.navigateTo({
      url: './../data/data',
    })
  },
  gotoDetail(e) {
    console.log(e)
    wx.navigateTo({
      url: '../identifyDetail/identifyDetail?detectId=' + e.currentTarget.dataset.id,
    })
  }


})